<?php
namespace Admin\Controller;
class ScreenController extends AdminController
{
    public function index()
    {
        $map['sid']  =   array('eq',I('id'));
        $list   = $this->lists('ShopStoreScreen', $map);
        int_to_string($list);
        foreach ($list as &$v){
            $v['store_name'] = M('ShopStore')->where(['id'=>$v['sid']])->getField('title');
        }
        $this->assign('_list', $list);
        $this->meta_title = '分屏管理';
        $this->display();
    }
    public function changeStatus($method=null)
    {
        $id = array_unique((array)I('id',0));
        $id = is_array($id) ? implode(',',$id) : $id;
        if ( empty($id) ) {
            $this->error('请选择要操作的数据!');
        }
        $map['id'] =   array('in',$id);
        switch ( strtolower($method) ){
            case 'forbid':
                $this->forbid('ShopStoreScreen', $map );
                break;
            case 'resume':
                $this->resume('ShopStoreScreen', $map );
                break;
            case 'delete':
                $this->delete('ShopStoreScreen', $map );
                break;
            default:
                $this->error('参数非法');
        }
    }
    public function edit()
    {
        $id = I('get.id');
        empty($id) && $this->error('参数不能为空！');
        $data = M('ShopStoreScreen')->field(true)->find($id);
        $this->assign('info',$data);
        $this->meta_title = '编辑分屏';
        $this->display();
    }
    public function add()
    {
        $id = I('post.id');
        empty($id) && $this->error('参数不能为空！');
        $data = I('post.');
        unset($data['id']);
        M('ShopStoreScreen')->where(['id'=>$id])->save($data);
        $this->success('执行成功');
    }
}